#include <stdio.h>
#include <string.h>

#pragma pack(push, 1)
struct ethernet_frame_header
{
    unsigned char dest_mac[6];
    unsigned char src_mac[6];
    unsigned short type;
};
#pragma pack(pop)

void mac_to_string(const unsigned char mac[6], char *str)
{
    snprintf(str, 18, "%02X:%02X:%02X:%02X:%02X:%02X",
             mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}

//测试函数
int main()
{
    struct ethernet_frame_header frame;
    memset(frame.dest_mac, 0xFF, 6);
    unsigned char src_mac[] = {0x00, 0x1A, 0x2B, 0x3C, 0x4D, 0x5E};
    memcpy(frame.src_mac, src_mac, 6);
    frame.type = 0x0800;

    char dest_mac_str[18], src_mac_str[18];
    mac_to_string(frame.dest_mac, dest_mac_str);
    mac_to_string(frame.src_mac, src_mac_str);

    printf("Ethernet Frame Header:\n");
    printf("Destination MAC: %s\n", dest_mac_str);
    printf("Source MAC: %s\n", src_mac_str);
    printf("Type: 0x%04X\n", frame.type);

    return 0;
}